package com.oocl.ha.merchant.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import com.oocl.ha.entity.Order;
import com.oocl.ha.merchant.service.OrderManager;

@Controller
public class WebServiceController {
	@Autowired
	private OrderManager mom;

	@RequestMapping(value = "/order/{oid}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
	@ResponseBody
	public String getOrder(@PathVariable Integer oid) {
		Order order=mom.findOrderById(oid);
		ObjectMapper mapper=new ObjectMapper();
		String oJson = null;
		try {
			oJson = mapper.writeValueAsString(order);
		} catch (JsonProcessingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return oJson;
	}

	

}
